package com.ks.test.fastjson;

import java.util.LinkedHashMap;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;

/**
 * fastjson 处理顺序json 字符串
 * @author pks
 * @version 2019年6月25日 
 */
public class LinkedMap {

	public static void main(String[] args) throws Exception {
		LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
		map.put("aaa", "asdjfag");
		map.put("bbb", "shhfdsht");
		map.put("ccc", "miekrh");
		String s = JSON.toJSONString(map);
		System.out.println(s);
		LinkedHashMap<String, String> jsonMap = JSON.parseObject(s, new TypeReference<LinkedHashMap<String, String>>() {});
        for (Map.Entry<String, String> entry : jsonMap.entrySet()) {
            System.out.println(entry.getKey() + ":" + entry.getValue());
        }
	}	
}
